package com.qqt.csr.route.enums;

import cn.hutool.extra.spring.SpringUtil;
import com.qqt.csr.route.service.strategy.cs.CsLastLeastDistribution;
import com.qqt.csr.route.service.strategy.cs.CsRandomDistribution;
import com.qqt.csr.route.service.strategy.cs.ICsDistribution;
import lombok.Getter;

/**
 * 客服分配策略枚举
 */
@Getter
public enum CsDistributionTypeEnum {

    RANDOM(0, "随机", SpringUtil.getBean(CsRandomDistribution.class)),
    LAST_LEAST(1, "熟客优先", SpringUtil.getBean(CsLastLeastDistribution.class)),
    ;

    private Integer value;
    private String desc;
    private ICsDistribution csDistribution;

    CsDistributionTypeEnum(int value, String desc, ICsDistribution csDistribution) {
        this.value = value;
        this.desc = desc;
        this.csDistribution = csDistribution;
    }

    public static CsDistributionTypeEnum getByValue(Integer value) {
        for (CsDistributionTypeEnum csDistributionTypeEnum : values()) {
            if (csDistributionTypeEnum.getValue().equals(value)) {
                return csDistributionTypeEnum;
            }
        }
        return null;
    }
}
